package com.easyadmin.modules.stock.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.easyadmin.common.web.domain.request.PageDomain;
import com.easyadmin.modules.stock.domain.SysStocksDayPrice;
import com.easyadmin.modules.stock.mapper.SysStocksDayPriceDao;
import com.easyadmin.modules.stock.service.SysStocksDayPriceService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;


@Service("sysStocksDayPriceService")
public class SysStocksDayPriceServiceImpl extends ServiceImpl<SysStocksDayPriceDao, SysStocksDayPrice>
        implements SysStocksDayPriceService {

    @Autowired
    private SysStocksDayPriceDao sysStocksDayPriceDao;


    @Override
    public PageInfo<SysStocksDayPrice> queryPage(SysStocksDayPrice sysStocksDayPrice, PageDomain pageDomain) {
        PageHelper.startPage(pageDomain.getPage(), pageDomain.getLimit());
        List<SysStocksDayPrice> data =sysStocksDayPriceDao.selectList(new QueryWrapper<SysStocksDayPrice>().lambda()
                .like(StringUtils.isNotBlank(sysStocksDayPrice.getStockName()),
                        SysStocksDayPrice::getStockName,sysStocksDayPrice.getStockName())
                .like(StringUtils.isNotBlank(sysStocksDayPrice.getStockCode()),
                        SysStocksDayPrice::getStockCode,sysStocksDayPrice.getStockCode())
                .like(StringUtils.isNotBlank(sysStocksDayPrice.getExchange()),
                        SysStocksDayPrice::getExchange,sysStocksDayPrice.getExchange())
                .orderBy(true,false,SysStocksDayPrice::getCreateTime,SysStocksDayPrice::getStockName));
        return new PageInfo<>(data);
    }
}
